<?php


namespace common\models;

use Yii;

class Redis
{
    public static function getReadCount(){
        $modelId = Yii::$app->controller->module->id;
        $pathInfo = Yii::$app->request->pathInfo;
        $readCount = Yii::$app->redis->hget("read_count", $modelId. ":" . $pathInfo);
        if(!$readCount){
            $readCount = 1;
        }
        Yii::$app->redis->hset("read_count", $modelId. ":" . $pathInfo, $readCount + 1);
        return $readCount;
    }
}